import Vue from 'vue'
import App from './App.vue'
import ElementUI from 'element-ui'
import 'element-ui/lib/theme-chalk/index.css'
import router from './router'
import store from './store'
import myaxios from './myaxios/myaxios'
Vue.use(ElementUI)

Vue.config.productionTip = false
Vue.prototype.myaxios=myaxios
// Vue.prototype.ws=new WebSocket('ws://192.168.0.98:3000')
router.beforeEach((to,from,next)=>{
  from
  if(to.meta.islogin){
    if(localStorage.getItem("loginmsg")!="null"&&localStorage.getItem("loginmsg")){
      next()
    }else{
      ElementUI.MessageBox('登录失效，请重新登录！', '系统提示：', {
        confirmButtonText: '确定',
      });
      next("/login")
    }
  }else if(to.meta.islogin2){
    if(localStorage.getItem("token")!="false"&&localStorage.getItem("token")){
      next()
    }else{
      ElementUI.MessageBox('登录失效，请重新登录！', '系统提示：', {
        confirmButtonText: '确定',
      });
      next("/about")
    }
  }else{
    next()
  }
})
new Vue({
  router,
  store,
  render: h => h(App),
}).$mount('#app')
